package com.example.module_main.ui.main

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.lib_common.base.BaseViewModel
import com.example.module_main.model.AppUpdateModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(private val repository: MainRepository): BaseViewModel() {
    private val appUpdateLiveData by lazy{
        MutableLiveData<AppUpdateModel>()
    }

    val appUpdateLiveData_: LiveData<AppUpdateModel> = appUpdateLiveData

    /**
     * 版本更新
     */
    fun checkUpdate(){
        execute(
            action = repository.checkUpdate(),
            onFinish = {
                appUpdateLiveData.value = it.data
            }
        )
    }
}